#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
    if (argc != 3) {
        cout << "Usage: " << argv[0] << " string dictfile" << endl;
        return 0;
    }

    string s(argv[1]);
    vector<string> dict;

    fstream fs;
    fs.open(argv[2], iostream::in);
    if (!fs.is_open()) {
        cout << "File " << argv[2] << " open error!" << endl;
        return 1;
    }

    string str;
    while (fs >> str) {
        dict.push_back(str);
    }
    fs.close();

    vector<int> index;
    index = findSubstring(s, dict);

    for (auto it = index.begin(); it != index.end(); it++) {
        cout << *it << endl;
    }

    return 0;
}

